import axios from '@/utils/request'

export const getArticleList = (page, cateid) =>
  axios({
    method: 'GET',
    url: '/index/list',
    params: {
      limit: 20,
      page,
      cateid
    }
  })

/** 获取文章详情
 *
 * @param {*} id 文章id
 * @returns
 */
export const getArtilceDetail = (id) =>
  axios({
    url: '/index/show',
    params: {
      id
    }
  })

/** 点赞/取消点赞和收藏/取消收藏
 *
 * @param {*} params 传入对象 type artcle_id action
 * @returns
 */
export const addLike = (params) =>
  axios({
    method: 'GET',
    url: '/user/userDataHandle',
    params
  })

/**  获取我的点赞收藏文章
 *
 * @param {*} page  页码
 * @param {*} type 类型 1点赞 2收藏
 * @returns
 */
export const getDataList = (page, type) =>
  axios({
    url: '/user/userDataList',
    params: {
      limit: 10,
      page,
      type
    }
  })

/** 获取我的文章
 *
 * @param {*} page 页码数
 * @returns
 */
export const getMyArticle = (page) =>
  axios({
    url: '/user/myArticle',
    params: {
      page
    }
  })

export const addArticle = (data) =>
  axios({
    method: 'POST',
    url: '/user/addArticle',
    data
  })

/** 删除我的文章
 *
 * @param {*} id  传入文章id
 * @returns
 */
export const delMyArticle = (id) =>
  axios({
    url: '/user/delArticle',
    params: {
      id
    }
  })

/** 修改我的文章
 *
 * @param {*} data 传入对象 修改文章的参数
 * @returns
 */
export const editArticle = (data) => axios.post('/user/editArticle', data)
